package com.mysecurity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.mysecurity.pojo.Permission;
import com.mysecurity.pojo.RolePermission;
import com.mysecurity.service.PermissionService;
import com.mysecurity.mapper.PermissionMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission>
    implements PermissionService{


    @Resource
    PermissionMapper permissionMapper;
    @Override
    public List<Permission> getPermissionByRoleId(Long roleId) {
        List<Permission> permissions = permissionMapper.selectJoinList(Permission.class
                , new MPJLambdaWrapper<Permission>()
                        .selectAll(Permission.class)
                        .innerJoin(RolePermission.class, RolePermission::getPermissionId, Permission::getId)
                        .eq(RolePermission::getRoleId, roleId));
     return permissions;
    }
}




